import {IShopItem, IShopcartItemParams, ISubmitOrderParams} from "../types/cart";
import {CategoryData} from "../types/test";
import {instanceS} from "../utils/request";

/* 测试获取尚品汇的三级分类数据接口 */
export const reqCategory = () => {
  return instanceS.get<any, CategoryData>(`/api/product/getBaseCategoryList`);
};
/**
 * @description 获取购物车列表
 * @returns
 */
export const reqGetShopCart = () => {
  return instanceS.get<any, IShopItem>(`/api/cart/cartList`);
};
/**
 * @description 添加或减少商品数量
 * @param skuID
 * @param skuNum
 * @returns
 */
export const reqEditGoodsNum = (skuId: number, skuNum: number) => {
  return instanceS.post(`/api/cart/addToCart/${skuId}/${skuNum}`);
};
/**
 * @description 更改商品选中状态
 * @param skuID
 * @param isChecked
 * @returns
 */
export const reqCheckCart = (skuID: number, isChecked: number) => {
  return instanceS.get(`/api/cart/checkCart/${skuID}/${isChecked}`);
};
/**
 * @description 全选
 * @param isChecked
 * @param data
 * @returns
 */
export const reqAllChecked = (isChecked: number, data: any) => {
  return instanceS.post(`/api/cart/batchCheckCart/${isChecked}`, data);
};
/**
 * @description 购物车删除单个商品
 * @param skuId
 * @returns
 */
export const reqDelGoods = (skuId: number) => {
  return instanceS.delete(`/api/cart/deleteCart/${skuId}`);
};
/**
 * @description 获取用户地址
 * @returns 
 */
export const reqGetAddressList = () => {
  return instanceS.get(`/api/user/userAddress/auth/findUserAddressList`)
}
/**
 * @description 获取交易页信息
 * @returns 
 */
export const reqGetTradeInfo = () => {
  return instanceS.get(`/api/order/auth/trade`)
}
/**
 * @description 提交订单
 * @param tradeNo 
 * @param data 
 * @returns 
 */
export const reqSubmitOrder = (tradeNo:string,data:ISubmitOrderParams) => {
  return instanceS.post(`/api/order/auth/submitOrder?tradeNo=${tradeNo}`,data)
}
/**
 * @description 获取订单支付信息
 * @param orderId 
 * @returns 
 */
export const reqGetPayInfo = (orderId:string) => {
  return instanceS.get(`/api/payment/weixin/createNative/${orderId}`)
}
/**
 * @description 查询订单支付状态
 * @param orderId 
 * @returns 
 */
export const reqGetPayStatus = (orderId:string) => {
  return instanceS.get(`/api/payment/weixin/queryPayStatus/${orderId}`)
}
/**
 * @description 获取我的订单列表
 * @param page 
 * @param limit 
 * @returns 
 */
export const reqGetOrderList =(page:number,limit:number)=>{
  return instanceS.get(`/api/order/auth/${page}/${limit}`)
}